nclude <pthread.h>
#include <stdio.h>

char *x[]=
	{ 
	"hickory dickory dock, " ,
	"the mouse ran up the clock, " ,
	"the clock struck one, " ,
	"the mouse ran down, " ,
	"hickory dickory dock. " 
	} ;

int number = 5 ;
int count = 3 ;

void *thread_function(void *arg)
{
int i , num ;

num = (int)arg ;

for (i = 0; i < count ; i++) 
	{
	write( 1 , x[ num ] , strlen( x[num] ) ) ;
	pthread_yield_np();
	sleep(1); 
	}
return( 0 ) ;
}

int main( int argc , char **argv )
{
pthread_t thread;
int i ;

for(i = 0; i < number ; i++) 
	{
	if (pthread_create(&thread, NULL, thread_function , (void *) i)) 
		printf("failed to create thread %d\n", i);
	pthread_yield_np();
	}
pthread_exit( 0 ) ;
}
